package com.hlw.hr_man.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hlw.hr_man.Model.EmployeeModel;
import com.hlw.hr_man.service.EmployeeSrevice;
import com.hlw.hr_man.serviceImpl.EmployeeServiceImpl;

import net.sf.json.JSONObject;

/**
 * 
 * @ClassName: GetEmpByEnumController
 * @Description: 处理根据员工编号获取员工信息的请求
 * @author 唐明
 * @date 2016年9月20日 上午10:11:35
 *
 */
public class GetEmpByEnumController extends HttpServlet{

	/**
	 * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
	 */ 
	private static final long serialVersionUID = 1L;
	
	EmployeeSrevice eService = new EmployeeServiceImpl();

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		resp.setCharacterEncoding("utf-8");
		String e_number = req.getParameter("e_number");
		EmployeeModel emp = eService.getEmployeeByEnumber(e_number);
		PrintWriter pw = resp.getWriter();
		pw.write(JSONObject.fromObject(emp).toString());;
	}
}
